<template>
  <div class="ffu_total">
    <iframe
      id="preivewFrame"
      class="iframe-con"
      scrolling="no"
      :src="`${VITE_FANRUAN_BASE_URL}/webroot/decision/view/duchamp?viewlet=energy/${templateName}&startTime=${queryParams.startTime}&endTime=${queryParams.endTime}&factory=${queryParams.factory}&op=view`"
      frameborder="0"
    />
  </div>
</template>

<script setup>
import { ref, onMounted, nextTick, computed } from "vue";

const { VITE_FANRUAN_BASE_URL } = import.meta.env;

const props = defineProps({
  timeType: {
    type: String,
    default: ""
  },
  queryParams: {
    type: Object,
    default: () => {}
  }
});

const templateName = computed(() => {
  switch (props.timeType) {
    case "Daily":
      return encodeURIComponent(encodeURIComponent("energyBalanceDaily")) + ".fvs";
      break;
    case "Monthly":
      return encodeURIComponent(encodeURIComponent("energyBalanceMonthly")) + ".fvs";
      break;
    case "Yearly":
      return encodeURIComponent(encodeURIComponent("energyBalanceYearly")) + ".fvs";
      break;
    default:
      return encodeURIComponent(encodeURIComponent("energyBalanceMonthly")) + ".fvs";
      break;
  }
});
</script>

<style lang="scss" scoped>
.ffu_total_wrap {
  position: relative;
  width: 100%;
  height: calc(100vh - 230px);
  background-color: #fff;

  .iframe-con {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    overflow: hidden !important;
    border: 0;
  }
}
</style>
